#include "quote.h"
#include <string.h>

DLL_EXPORT_C_DECL void *WINAPI qCreateApi() { return ctp_sopt::CThostFtdcMdApi::CreateFtdcMdApi("./log/"); }
DLL_EXPORT_C_DECL void *WINAPI qGetApiVersion() { return (void*)ctp_sopt::CThostFtdcMdApi::GetApiVersion(); }
DLL_EXPORT_C_DECL void *WINAPI qCreateSpi() { return new Quote(); }
// req
DLL_EXPORT_C_DECL void WINAPI qRelease(ctp_sopt::CThostFtdcMdApi *api) { api->Release(); }
DLL_EXPORT_C_DECL void WINAPI qInit(ctp_sopt::CThostFtdcMdApi *api) { api->Init(); }
DLL_EXPORT_C_DECL void WINAPI qJoin(ctp_sopt::CThostFtdcMdApi *api) { api->Join(); }
DLL_EXPORT_C_DECL void WINAPI qRegisterFront(ctp_sopt::CThostFtdcMdApi *api, char *pszFrontAddress) { api->RegisterFront(pszFrontAddress); }
DLL_EXPORT_C_DECL void WINAPI qRegisterNameServer(ctp_sopt::CThostFtdcMdApi *api, char *pszNsAddress) { api->RegisterNameServer(pszNsAddress); }
DLL_EXPORT_C_DECL void WINAPI qRegisterFensUserInfo(ctp_sopt::CThostFtdcMdApi *api, CThostFtdcFensUserInfoField *pFensUserInfo) { api->RegisterFensUserInfo(pFensUserInfo); }
DLL_EXPORT_C_DECL void WINAPI qRegisterSpi(ctp_sopt::CThostFtdcMdApi *api, ctp_sopt::CThostFtdcMdSpi *pSpi) { api->RegisterSpi(pSpi); }
DLL_EXPORT_C_DECL void WINAPI qSubscribeMarketData(ctp_sopt::CThostFtdcMdApi *api, char *ppInstrumentID[], int nCount) { api->SubscribeMarketData(ppInstrumentID, nCount); }
DLL_EXPORT_C_DECL void WINAPI qUnSubscribeMarketData(ctp_sopt::CThostFtdcMdApi *api, char *ppInstrumentID[], int nCount) { api->UnSubscribeMarketData(ppInstrumentID, nCount); }
DLL_EXPORT_C_DECL void WINAPI qSubscribeForQuoteRsp(ctp_sopt::CThostFtdcMdApi *api, char *ppInstrumentID[], int nCount) { api->SubscribeForQuoteRsp(ppInstrumentID, nCount); }
DLL_EXPORT_C_DECL void WINAPI qUnSubscribeForQuoteRsp(ctp_sopt::CThostFtdcMdApi *api, char *ppInstrumentID[], int nCount) { api->UnSubscribeForQuoteRsp(ppInstrumentID, nCount); }
DLL_EXPORT_C_DECL void WINAPI qReqUserLogin(ctp_sopt::CThostFtdcMdApi *api, CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) { api->ReqUserLogin(pReqUserLoginField, nRequestID); }
DLL_EXPORT_C_DECL void WINAPI qReqUserLogout(ctp_sopt::CThostFtdcMdApi *api, CThostFtdcUserLogoutField *pUserLogout, int nRequestID) { api->ReqUserLogout(pUserLogout, nRequestID); }

// reg
DLL_EXPORT_C_DECL void WINAPI qSetOnFrontConnected(Quote *spi, void *func) { spi->_OnFrontConnected = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnFrontDisconnected(Quote *spi, void *func) { spi->_OnFrontDisconnected = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnHeartBeatWarning(Quote *spi, void *func) { spi->_OnHeartBeatWarning = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnRspUserLogin(Quote *spi, void *func) { spi->_OnRspUserLogin = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnRspUserLogout(Quote *spi, void *func) { spi->_OnRspUserLogout = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnRspError(Quote *spi, void *func) { spi->_OnRspError = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnRspSubMarketData(Quote *spi, void *func) { spi->_OnRspSubMarketData = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnRspUnSubMarketData(Quote *spi, void *func) { spi->_OnRspUnSubMarketData = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnRspSubForQuoteRsp(Quote *spi, void *func) { spi->_OnRspSubForQuoteRsp = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnRspUnSubForQuoteRsp(Quote *spi, void *func) { spi->_OnRspUnSubForQuoteRsp = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnRtnDepthMarketData(Quote *spi, void *func) { spi->_OnRtnDepthMarketData = func; }
DLL_EXPORT_C_DECL void WINAPI qSetOnRtnForQuoteRsp(Quote *spi, void *func) { spi->_OnRtnForQuoteRsp = func; }
